// 
//  EVECDLearnedSkill.m
//  EVE Mac Suite
//
//  Created by Vadim Lozko on 6/21/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "EVECDLearnedSkill.h"
#import "EVECDLearnedGroup.h"
#import "EVECDSkill.h"
#import "EVECDQueueItem.h"
#import "EVECDSkillPlanItem.h"
#import "EMSGeneralUtils.h"
#import "EMSSkillTrainingInfo.h"

@implementation EVECDLearnedSkill 

@dynamic learningStart;
@dynamic currentlyInTraining;
@dynamic level;
@dynamic partOfLearnedGroup;
@dynamic skill;
@dynamic partOfQueueItem;
@dynamic partOfSkillPlanItem;

- (NSManagedObjectID*)displayInfo 
{
	return self.objectID;
}
/*
-(void)setSkillPointsLearned:(NSNumber*)points
{
	[self willAccessValueForKey:@"level"];
	[self willAccessValueForKey:@"skillPointsLearned"];
	[self setPrimitiveValue:points forKey:@"skillPointsLearned"];
	[self didAccessValueForKey:@"skillPointsLearned"];
	[self didAccessValueForKey:@"level"];
}*/

-(NSNumber*)level
{
	int skillPointsLearned = [[self primitiveValueForKey:@"skillPointsLearned"] intValue];
	int rank = [[[self primitiveValueForKey:@"skill"] primitiveValueForKey:@"rank"] intValue];
	int level = [EMSSkillTrainingInfo levelForSkillPoints:skillPointsLearned rank:rank];
	return [NSNumber numberWithInt:level];
}

-(NSString*)description
{
	return [NSString stringWithFormat:@"Learned Skill Name: %@\n%@", self.skill.name, [super description]];
}


@end

@implementation EVECDLearnedSkill (BindingsAccessors)

-(NSString*)name
{
	return self.skill.name;
}

-(BOOL)isLeaf
{
	return YES;
}

@end